package com.ljxt.dt.vo.purchasingmanagement;

import com.ljxt.dt.domain.GoodsInfo;
import com.ljxt.dt.domain.PurchaseDetail;
import com.ljxt.dt.domain.SupplierInfo;
import com.ljxt.dt.util.xhq.StringUtil;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * 自定义的 Vo 用来代表主界面显示的 Vo
 * @author 徐浩钦
 * @version 1.0.0
 * @date 2020/5/12 11:40
 * @copyright 老九学堂T11
 */
public class PurchaseMainVo {
    // 成员属性： 单据状态，单据 Id

    // 单据状态
    private String documentsState;
    // 创建时间的字符串形式
    private String strTime;

    // 单据 ID
    private Integer id;
    // 单据编号
    private String orderNo;
    // 流程 ID
    private Integer stateId;
    // 创建时间
    private Date createTime;
    // 单据备注
    private String remarks;

    // 供应商 的对象
    private SupplierInfo supplier;
    // 供应商 的对象名称
    private String supplierName;
    // 所属的商品名称集合
    private List<String> goodsInfoNames = new ArrayList<>();
    // 所属的商品对象
    private List<GoodsInfo> goodsInfos;

    private List<PurchaseDetail> purchaseDetails;

    // 单据的金额
    private double money = 0d;
    // 供应商名称
    private String tradeName;


    public List<String> getGoodsInfoNames() {
        return goodsInfoNames;
    }

    public void setGoodsInfoNames(List<String> goodsInfoNames) {
        this.goodsInfoNames = goodsInfoNames;
    }

    public List<GoodsInfo> getGoodsInfos() {
        return goodsInfos;
    }

    /**
     * 设置采购顶大的明细信息 并设置相关的明细商品名称的集合
     * @param goodsInfos
     */
    public void setGoodsInfos(List<GoodsInfo> goodsInfos) {
        this.goodsInfos = goodsInfos;
        // 循环为商品名称的集合添加
        for (GoodsInfo goodsInfo : goodsInfos) {
            this.goodsInfoNames.add(goodsInfo.getGoodsName());
        }
    }

    /**
     * 设置采购订单的相关供应商并设置相关的名称
     * @param supplier
     */
    public void setSupplier(SupplierInfo supplier) {
        this.supplier = supplier;
        // 将名称取出
        this.supplierName = supplier.getSupplierName();
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
        this.setStrTime(StringUtil.dateFormat(this.createTime));
    }


    /**
     * 用来将时间格式的 format 方法
     */
    public void strTimeFormat(){
        this.setStrTime(StringUtil.dateFormat(this.createTime));
    }

    //---------------------------------------------------------------------------------

    public List<PurchaseDetail> getPurchaseDetails() {
        return purchaseDetails;
    }

    public double getMoney() {
        return money;
    }

    public void setMoney(double money) {
        this.money = money;
    }

    public String getTradeName() {
        return tradeName;
    }
    public void setTradeName(String tradeName) {
        this.tradeName = tradeName;
    }

    @Override
    public String toString() {
        return "PurchaseMainVo{" +
                "documentsState='" + documentsState + '\'' +
                ", strTime='" + strTime + '\'' +
                ", id=" + id +
                ", orderNo='" + orderNo + '\'' +
                ", stateId=" + stateId +
                ", createTime=" + createTime +
                ", remarks='" + remarks + '\'' +
                ", supplier=" + supplier +
                ", supplierName='" + supplierName + '\'' +
                ", goodsInfoNames=" + goodsInfoNames +
                ", goodsInfos=" + goodsInfos +
                ", purchaseDetails=" + purchaseDetails +
                ", money=" + money +
                ", tradeName='" + tradeName + '\'' +
                '}';
    }

    public String getDocumentsState() {
        return documentsState;
    }

    public void setDocumentsState(String documentsState) {
        this.documentsState = documentsState;
    }

    public String getStrTime() {
        return strTime;
    }

    public void setStrTime(String strTime) {
        this.strTime = strTime;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }


    public void setPurchaseDetails(List<PurchaseDetail> purchaseDetails) {
        this.purchaseDetails = purchaseDetails;
    }
    public String getSupplierName() {
        return supplierName;
    }

    public void setSupplierName(String supplierName) {
        this.supplierName = supplierName;
    }

    public String getOrderNo() {
        return orderNo;
    }

    public void setOrderNo(String orderNo) {
        this.orderNo = orderNo;
    }

    public Integer getStateId() {
        return stateId;
    }

    public void setStateId(Integer stateId) {
        this.stateId = stateId;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public String getRemarks() {
        return remarks;
    }

    public void setRemarks(String remarks) {
        this.remarks = remarks;
    }

    public SupplierInfo getSupplier() {
        return supplier;
    }
}
